package com.fzy.common.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 验证码检验
 *
 * @author 冯赵杨
 * @create 2018/9/27
 */
public class SessionCheckCodeServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException, IOException {
        try {
            response.setContentType("text/html;charset=GB2312");
            PrintWriter out = response.getWriter();

            String checkCode = request.getSession().getAttribute("icheckCode").toString();
            if (checkCode == null) {
                checkCode = "";
            }
            checkCode = checkCode.toLowerCase();
            out.print(checkCode);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        doGet(req, resp);

    }
}
